package com.SmartLED.Common;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Frozen on 2017/1/9.
 */

@SpringBootApplication
@Component
public class SYS_Base {
    protected String errorCode = "";    //错误代码

    protected Integer operator_id;       //操作者 ID


    protected void setErrorCode(String code)
    {
        if (errorCode.isEmpty())
        {
            errorCode = code;
        }
    }


    //返回错误信息
    protected String sendErrorByCode(String error_code) throws JsonProcessingException {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        resultMap.put("code", 1);
        resultMap.put("data", "");
        resultMap.put("msg", Error_config.errorMap.get(error_code));
        return new ObjectMapper().writeValueAsString(resultMap);
    }

}
